package com.redsoil.house.ui.matter.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.redsoil.house.R;
import com.redsoil.house.base.BaseViewHolderTSK;
import com.redsoil.house.model.bean.MessageListVO;
import com.redsoil.house.model.bean.MySection;

import java.util.List;

/**
 * Created by weidingqiang on 2018/12/19.
 */

public class MatterAdapter extends BaseSectionQuickAdapter<MySection, BaseViewHolderTSK> {

    public MatterAdapter(int layoutResId, int sectionHeadResId, List data) {
        super(layoutResId, sectionHeadResId, data);
    }

    @Override
    protected void convertHead(BaseViewHolderTSK helper, final MySection item) {
        helper.setText(R.id.title_tv, item.getHeader());
//        helper.setVisible(R.id.more, item.isMore());
//        helper.addOnClickListener(R.id.more);
    }


    @Override
    protected void convert(BaseViewHolderTSK helper, MySection item) {
        MessageListVO.DataListBean bean = (MessageListVO.DataListBean) item.t;

        //1.首先判断是否为编辑状态
        if(bean.getEdit()){
            //是否勾选
            if(bean.getSelected()){
                helper.setImageResource(R.id.checkbox_img,R.drawable.icon_check_selected);
                helper.setBackgroundColor(R.id.matter_list_content_item_layout,mContext.getResources().getColor(R.color.orange7ce));
            }
            else {
                helper.setImageResource(R.id.checkbox_img,R.drawable.icon_check_normal);
                helper.setBackgroundColor(R.id.matter_list_content_item_layout,mContext.getResources().getColor(R.color.white4ed));
            }
            helper.setVisible(R.id.checkbox_img,true);
        }else {
            helper.setBackgroundColor(R.id.matter_list_content_item_layout,mContext.getResources().getColor(R.color.white4ed));
            //判断已读未读
            //是否已读：1是/0否
            if(bean.getIsRead().equals("0")){
                helper.setImageResource(R.id.checkbox_img,R.drawable.bottom_circle_bg);
                helper.setVisible(R.id.checkbox_img,true);
            }else {
                ImageView imageView = (ImageView) helper.getView(R.id.checkbox_img);
                imageView.setVisibility(View.INVISIBLE);
            }
        }

        //根据
//        bean.getSelected() 去切换 checkbox_img 状态

        helper.setText(R.id.title_tv,bean.getTitle());

        helper.setVisible(R.id.key_point_img,bean.getIsImportance().equals("0")? false : true);

        helper.setVisible(R.id.lock_img,bean.getIsLock().equals("0")? false : true);

        if(bean.getIsSure().equals("1")){
            helper.setVisible(R.id.sure_img, true);
        }else {
            helper.setVisible(R.id.sure_img,false );
        }



        helper.setText(R.id.content_tv,bean.getContent());

    }
}
